if /I "%1" == "-h" (
	call :usage
	exit /B 1
)
call common\function.bat parse_args %*

if not !errorlevel! EQU 0 exit /B 1

if not exist !j_cmake! (
	echo "cmake not found. Try 'jenny update' please"
	exit /B 1
)

set j_defines=-DPROJECT_FILE=!j_config_path! -DCMAKE_BUILD_TYPE=!j_config! -DJ_TARGET_PLATFORM=!j_platform!  -DJ_ARCHITECTURE=!j_architecture! -DJ_TOOLSET=!j_toolset! -DJ_TOOLSET_VER=!j_toolset_ver!

for /F "usebackq delims=#" %%i in (`!j_cmake! !j_defines! -P !j_jenny_root_dir!/cmake/prepare.cmake`) do (
    set lvar=%%i
	set !lvar:~3!
)

set j_generated_project_dir=!j_generated_project_dir:/=\!
echo removing !j_generated_project_dir! ...
rd /s /q "!j_generated_project_dir!"

echo Done. you may need to clean run folder !j_output_root_dir!/run.

exit /B

:usage
	echo "Usage: jenny clean"
	exit /B 1
